package com.example.add_sub;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    TextView num;
    Button btnone,btntwo,btnthree;
    int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        btnone = findViewById(R.id.btn_1);
        btntwo = findViewById(R.id.btn_2);
        btnthree = findViewById(R.id.btn_3);
        num = findViewById(R.id.num_1);

        btnone.setOnClickListener(this);
        btntwo.setOnClickListener(this);
        btnthree.setOnClickListener(this);


    }



    @Override
    public void onClick(View v) {
        int id = v.getId();


        if(id == R.id.btn_1)
        {
            i--;
            num.setText(String.valueOf(i));
        }
        if(id == R.id.btn_2)
        {
            i=0;
            num.setText(String.valueOf(i));

        }
        if(id == R.id.btn_3)
        {
            i++;
            num.setText(String.valueOf(i));
        }


    }


}